﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SystemContainer.Models;

namespace SystemContainer.Models
{
    public class Compute
    {
        private SystemEntities db = new SystemEntities();
        private Algorithm al;
        private DataSet data;

        public bool init()
        {
            /*int algorithmId, dataId;
            if(AlgoAndData.AlgorithmID !=0  && AlgoAndData.DataSetID!= 0)
            {
                algorithmId = AlgoAndData.AlgorithmID;
                dataId = AlgoAndData.DataSetID;
            
                al = db.Algorithms.Find(algorithmId);
                data = db.DataSets.Find(dataId);
                return true;
            }

            else 
                return false;*/
                return false;

        }

        /*返回一个图片地址的列表，如果返回null说明AlgoAndData没被初始化*/
        public string[] getNearByPhotos(Location location)
        {
            

            //如果选定了algorithm和dataset
            if (!init())
                return null;
            else
            {
                return MatlabWrapper.getNearByPhotos(location, al.Name, data.dir + data.Name);
            
            } 
        

        }


        public Place[] getHotPlaces(String areaName)
        {
            BoundFinder finder = new BoundFinder();
            double[] bounds = finder.findBound(areaName);
            return MatlabWrapper.getHotPlaces(bounds[0], bounds[1], bounds[2], bounds[3]);
        }
      
    }
}